package com.aliang.book_java1.po.redis;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.stereotype.Component;

/**
 * redis·消息队列
 * ZTX
 */
// 消息发布者
@Component
public class MessagePublisher {
    private final RedisTemplate<String, String> redisTemplate;
    private final ChannelTopic topic;

    public MessagePublisher(RedisTemplate<String, String> redisTemplate, ChannelTopic topic) {
        this.redisTemplate = redisTemplate;
        this.topic = topic;
    }

    public void publishMessage(String message) {
        redisTemplate.convertAndSend(topic.getTopic(), message);
    }

    public void doRedis(){
        redisTemplate.opsForValue().set("addWaitConvFile", "T");
    }
}

